﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Xaml.Media.Imaging;
using SQLite;
using wBudget.Common;
using System.ComponentModel;

namespace wBudget.Models
{
    public class Entry : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;

        public Entry() {
            ApplicationSettings.ApplicationSettingsChanged += UpdateAmountString;
        }

        public DateTime Date { get; set; }
        public double Amount { get; set; }

        [Ignore]
        public string FormattedAmountString
        {
            get
            {
                string s = Math.Round(Amount, 2).ToString("0.00");
                if (DataManager.UseCustomCurrency) s += " " + DataManager.CurrencyString;
                return s;
            }
        }

        public void UpdateAmountString() {
            PropertyChanged(this, new PropertyChangedEventArgs("FormattedAmountString"));
        }

        public int CategoryId { get; set; }
        public string Description { get; set; }

        [Ignore]
        public string Subtitle
        {
            get { return null; }
        }

        [Ignore]
        public BitmapImage Image
        {
            get
            {
                return DataManager.CategoryLogos[CategoryId];
            }
        }
    }
}
